#include <SimpleAmqpClient/SimpleAmqpClient.h>

#include <iostream>

int main()
{
    try
    {
        // 创建连接到 RabbitMQ 服务器
        AmqpClient::Connection::ptr_t connection = AmqpClient::Connection::Create("localhost");

        // 创建一个频道
        AmqpClient::Channel::ptr_t channel = AmqpClient::Channel::Create(connection);

        // 确保队列存在
        channel->DeclareQueue("hello", AmqpClient::Channel::QUEUE_DURABLE);

        // 发送消息
        channel->BasicPublish("", "hello", AmqpClient::BasicMessage::Create("Hello World!"));

        std::cout << " [x] Sent 'Hello World!'" << std::endl;
    }
    catch (const AmqpClient::AmqpException &ex)
    {
        std::cerr << "Error: " << ex.what() << std::endl;
    }

    return 0;
}
